package com.ruibang.glass.quality.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruibang.glass.quality.domain.req.DefectLossReq;
import com.ruibang.glass.quality.domain.req.EverydayDefectLossReq;
import com.ruibang.glass.quality.entity.EverydayDefectLoss;
import com.ruibang.glass.quality.mapper.EverydayDefectLossMapper;
import com.ruibang.glass.quality.service.EverydayDefectLossService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service
public class EverydayDefectLossServiceImpl extends ServiceImpl<EverydayDefectLossMapper, EverydayDefectLoss> implements EverydayDefectLossService {



    @Override
    public ResultBody queryEverydayDefectLoss(EverydayDefectLossReq everydayDefectLossReq) {
        final IPage<EverydayDefectLoss> page = new Page<>(everydayDefectLossReq.getPageNo(), everydayDefectLossReq.getPageSize());
        return ResultBody.success(baseMapper.queryEverydayDefectLoss(page, everydayDefectLossReq));
    }

    @Override
    public List<String> getAllTimeKey() {
        return baseMapper.getAllTimeKey();
    }

    @Override
    public List<EverydayDefectLoss> queryNotUpdateData() {
        return baseMapper.queryNotUpdateData();
    }

    @Override
    public ResultBody queryHotLoss(DefectLossReq defectLossReq) {
        return ResultBody.success(baseMapper.queryHotLoss(defectLossReq));
    }

    @Override
    public ResultBody queryColdLoss(DefectLossReq defectLossReq) {
        return ResultBody.success(baseMapper.queryColdLoss(defectLossReq));
    }

    @Override
    public ResultBody queryTotalLoss(DefectLossReq defectLossReq) {
        return ResultBody.success(baseMapper.queryTotalLoss(defectLossReq));
    }

    @Override
    public void deleteDayData(DefectLossReq defectLossReq) {
        baseMapper.deleteDayData(defectLossReq);
    }

    /**
     * @Description: 根据日期获取时间
     * @version v1.0
     * @author songJinKang
     * @date 2023-09-15 11:16
     */
    @Override
    public List<EverydayDefectLoss> getByDate(ArrayList<String> date) {
        QueryWrapper<EverydayDefectLoss> hlQw = new QueryWrapper<>();
        hlQw.lambda().in(EverydayDefectLoss::getDefectDate, date);
        return this.list(hlQw);
    }
}
